home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / comm / misc / RecentScript.lha / RecentScript / RecentScriptCmd.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1997-04-04  |  19.5 KB  |  813 lines

  1. /*****
  2.   $VER: RecentScript Commands 1.1 (3.4.97) ©Arndt van der Molen
  3.  
  4.  
  5.                    RecentScript Commands
  6.  
  7.   is a MUIRexx subapplication and can not be started directly.
  8.  
  9.   It is called only from the starter application.
  10. *****/
  11.  
  12.  
  13.  
  14. /* Change to path with trailing ':' or '/' where this script resides */
  15.  
  16. srcdir = 'MUIREXX:RecentScript/'
  17.  
  18.  
  19.  
  20. /* !!! NOTHING TO CHANGE BELOW THIS LINE !!! */
  21.  
  22. MUIV_List_Select_Off      =  0
  23. MUIV_List_Select_On       =  1
  24.  
  25. OPTIONS RESULTS
  26.  
  27. PARSE ARG portname cmd1 cmd2 '['cmd3']'
  28.  
  29.  
  30. cmd2 = STRIP(cmd2)
  31.  
  32. PRAGMA('Directory',srcdir)   /* Set current directory */
  33.  
  34. ADDRESS VALUE portname
  35.  
  36. IF ~SHOW('l', "rexxdossupport.library") then do
  37.   CALL addlib('rexxdossupport.library',0,-30,0)
  38. END
  39.  
  40. SELECT
  41.   
  42.   WHEN cmd1 = 'ADD'         THEN CALL addentries
  43.  
  44.   WHEN cmd1 = 'CLR'         THEN CALL clearlist cmd2
  45.  
  46.   WHEN cmd1 = 'DEL'         THEN CALL delentry
  47.  
  48.   WHEN cmd1 = 'LOAD'        THEN CALL loadindex cmd2 cmd3
  49.  
  50.   WHEN cmd1 = 'MINUS'       THEN CALL patternentries MUIV_List_Select_Off
  51.  
  52.   WHEN cmd1 = 'PLUS'        THEN CALL patternentries MUIV_List_Select_On
  53.  
  54.   WHEN cmd1 = 'SAVE'        THEN CALL savelist
  55.  
  56.   WHEN cmd1 = 'SETBAT'      THEN CALL batchsettingopen '['cmd3']'
  57.  
  58.   WHEN cmd1 = 'SETBATHDL'   THEN CALL batchsettinghandle cmd2 '['cmd3']'
  59.  
  60.   WHEN cmd1 = 'TEST'        THEN CALL testprocedure
  61.  
  62.   OTHERWISE DO
  63.     request ID RECSCRWIN TITLE '"Internal Error"' GADGETS '"_OK"' STRING '"Unsupport command 'cmd1 cmd2 cmd3'"'
  64.   END
  65. END
  66.  
  67. RETURN
  68.  
  69.  
  70.  
  71. /* --------------------------------------------------------- */
  72. /* Add all selected entries from the LST_ALL to the LST_SEL  */
  73. /* --------------------------------------------------------- */
  74.  
  75. addentries: PROCEDURE
  76.  
  77. MUIA_List_Quiet           = '0x8042d8c7'
  78. MUIM_Busy_Move            = '0x80020001'
  79. MUIV_List_Insert_Bottom   = -3
  80.  
  81.  
  82. list ID LST_SEL ATTRS MUIA_List_Quiet 1
  83.  
  84. DO FOREVER
  85.  
  86.   list ID LST_ALL
  87.   entry = RESULT
  88.  
  89.   IF entry = '' THEN LEAVE
  90.  
  91.   method ID CLS_BUSY MUIM_Busy_Move
  92.  
  93.   list ID LST_SEL NODUP POS MUIV_List_Insert_Bottom INSERT STRING entry
  94. END
  95.  
  96. list ID LST_SEL ATTRS MUIA_List_Quiet 0
  97.  
  98. RETURN
  99.  
  100.  
  101.  
  102. /* --------------------------------------------------------- */
  103. /* Delete selected entry from the LST_SEL                    */
  104. /* --------------------------------------------------------- */
  105.  
  106. delentry: PROCEDURE
  107.  
  108. MUIA_List_Active          = '0x8042391c'
  109.  
  110. list ID LST_SEL ATTRS MUIA_List_Active
  111. position = RESULT
  112.  
  113. list ID LST_SEL POS position STRING
  114.  
  115. RETURN
  116.  
  117.  
  118.  
  119. /* --------------------------------------------------------- */
  120. /* Load specified AmiNet index file into specified listview  */
  121. /* --------------------------------------------------------- */
  122.  
  123. loadindex: PROCEDURE EXPOSE srcdir
  124.  
  125. parse arg listid ' ' filename
  126.  
  127. MUIA_List_Quiet           = '0x8042d8c7'
  128. MUIM_Busy_Move            = '0x80020001'
  129. ASLFR_InitialDrawer       = '0x80080009'
  130. MUIV_List_Insert_Bottom   = -3
  131.  
  132.  
  133. IF filename = '' THEN DO
  134.  
  135.   OPTIONS FAILAT 11
  136.   aslrequest ID RECSCRWIN TITLE '"Load AmiNet index file..."' ATTRS ASLFR_InitialDrawer srcdir
  137.   returncode = RC
  138.   filename   = RESULT
  139.   OPTIONS FAILAT 0
  140.  
  141.   IF returncode ~= 0 | filename = '' THEN DO
  142.     RETURN
  143.   END
  144. END
  145.  
  146. IF OPEN(indexhandle, filename, 'R') THEN DO
  147.  
  148.   list ID listid ATTRS MUIA_List_Quiet 1
  149.  
  150.   DO UNTIL EOF(indexhandle)
  151.  
  152.     method ID CLS_BUSY MUIM_Busy_Move
  153.  
  154.     line = READLN(indexhandle)
  155.  
  156.     /* Check if the line is an AmiNet Index line */
  157.  
  158.     slashposition = POS('/',line)
  159.  
  160.     /* This check must be edited if the format of the index file changes */
  161.     IF    (SUBSTR(line,34,1) = 'K' | SUBSTR(line,34,1) = 'M'),
  162.         & SUBSTR(line,19,1)  = ' ',
  163.         & SUBSTR(line,30,1)  = ' ',
  164.         & SUBSTR(line,36,1) ~= ' ', /* Exlude 'most downloaded' and 'top rated' files */
  165.         & slashposition > 20,
  166.         & slashposition < 29
  167.     THEN DO
  168.  
  169.       /* This line must be edited if the format of the index file changes */
  170.       PARSE VAR line WITH 1 1 name +18 WITH 20 directory +10 WITH 31 size +4 WITH 36 comment
  171.  
  172.       LIST ID listid NODUP POS MUIV_List_Insert_Bottom INSERT STRING name","directory","size","comment
  173.     END
  174.   END
  175.  
  176.   list ID listid ATTRS MUIA_List_Quiet 0
  177.  
  178.   CALL CLOSE(indexhandle)
  179.  
  180. END
  181. ELSE DO
  182.   request ID RECSCRWIN TITLE '"File Error"' GADGETS "_OK" STRING "Cannot read file '"filename"'"
  183. END
  184.  
  185. RETURN
  186.  
  187.  
  188.  
  189. /* --------------------------------------------------------- */
  190. /* Save LST_SEL to AmiNet index file or user defined batch   */
  191. /* --------------------------------------------------------- */
  192.  
  193. savelist: PROCEDURE EXPOSE srcdir
  194.  
  195. MUIA_List_Entries         = '0x80421654'
  196. MUIM_Busy_Move            = '0x80020001'
  197. ASLFR_InitialFile         = '0x80080008'
  198. ASLFR_InitialDrawer       = '0x80080009'
  199.  
  200.  
  201. /* Get batchmode */
  202.  
  203. cycle ID CYC_BAT
  204. batchmode = RESULT
  205.  
  206. /* Save to AmiNet Index file ? */
  207.  
  208. IF batchmode = 'AmiNet Index' THEN DO
  209.   CALL saveasindex
  210.   RETURN
  211. END
  212.  
  213. /* An user configured batch mode is selected... */
  214.  
  215. /* Read global batchmode config in local stem */
  216.  
  217. IF loadbatchconfigs('['batchmode']') = 1 THEN DO
  218.  
  219.   locdir  = PATHPART(globalcfg.file)
  220.   locfile = FILEPART(globalcfg.file)
  221.  
  222.   OPTIONS FAILAT 11
  223.   aslrequest ID RECSCRWIN TITLE '"Save ''batchmode'' file ..."' ATTRS ASLFR_InitialDrawer locdir ASLFR_InitialFile locfile
  224.   returncode = RC
  225.   outputfilename   = RESULT
  226.   OPTIONS FAILAT 0
  227.  
  228.   IF returncode ~= 0 | outputfilename = '' THEN DO
  229.     RETURN
  230.   END
  231.  
  232.   IF OPEN(writehandle, outputfilename, 'W') THEN DO
  233.  
  234.     /* Read and Write batchmode intro file if available */
  235.  
  236.     filename = srcdir || "Configs/" || batchmode || ".intro"
  237.  
  238.     IF OPEN(handle, filename, 'R') THEN DO
  239.  
  240.       /* Do for all lines in file */
  241.       DO UNTIL EOF(handle)
  242.       
  243.         method ID CLS_BUSY MUIM_Busy_Move
  244.  
  245.         line = READLN(handle)
  246.  
  247.         /* Replace batch placeholders with value from config */
  248.         DO i=1 TO (batchcfg.0)
  249.  
  250.           /* Replace all placeholders in line */
  251.           start = POS(batchcfg.i.replace, line)
  252.           DO WHILE start ~= 0
  253.  
  254.             line  = SUBSTR(line,1,start-1) || SUBSTR(line,start+2)
  255.             line  = INSERT(batchcfg.i.val, line, start-1)
  256.             start = POS(batchcfg.i.replace, line)
  257.           END
  258.         END
  259.  
  260.         CALL WRITELN(writehandle, line)
  261.       END
  262.  
  263.       CALL CLOSE(handle)
  264.     END
  265.  
  266.  
  267.     /* Read and Write batchmode entry file if available */
  268.  
  269.     filename = srcdir || "Configs/" || batchmode || ".entry"
  270.  
  271.     IF OPEN(handle, filename, 'R') THEN DO
  272.  
  273.       /* Add entry placeholders to local stem varaible */
  274.       i = batchcfg.0 + 1
  275.       batchcfg.i.replace = '%n'     /* name      */
  276.       i = i+1
  277.       batchcfg.i.replace = '%d'     /* directory */
  278.       i = i+1
  279.       batchcfg.i.replace = '%s'     /* size      */
  280.       i = i+1
  281.       batchcfg.i.replace = '%c'     /* comment   */
  282.       batchcfg.0 = i
  283.  
  284.       /* Read batchmode entry lines in local stem variable */
  285.  
  286.       entrycfg.0 = 0
  287.       i = 1
  288.  
  289.       DO UNTIL EOF(handle)
  290.   
  291.         method ID CLS_BUSY MUIM_Busy_Move
  292.  
  293.         entrycfg.i = READLN(handle)
  294.         entrycfg.0 = i
  295.         i = i + 1
  296.       END
  297.  
  298.       CALL CLOSE(handle)
  299.  
  300.       /* Do for all entries in LST_SEL */
  301.  
  302.       list ID LST_SEL ATTRS MUIA_List_Entries
  303.       lstselcount = RESULT
  304.  
  305.       IF lstselcount > 0 THEN DO
  306.  
  307.         DO lstselnr=0 TO lstselcount-1
  308.  
  309.           method ID CLS_BUSY MUIM_Busy_Move
  310.  
  311.           list ID LST_SEL POS lstselnr
  312.           listline = RESULT
  313.  
  314.           /* This line must be edited if the format of the index file changes */
  315.           PARSE VAR listline WITH 1 name +18 WITH 20 directory +10 WITH 31 size +4 WITH 36 comment
  316.  
  317.           /* Add entry values to local stem varaible */
  318.           i = batchcfg.0
  319.           batchcfg.i.val = comment
  320.           i = i-1
  321.           batchcfg.i.val = size
  322.           i = i-1
  323.           batchcfg.i.val = STRIP(directory)
  324.           i = i-1
  325.           batchcfg.i.val = STRIP(name)
  326.  
  327.  
  328.           DO global=0 TO globalcfg.readme  /* Process *.readme file ? */
  329.  
  330.             IF global=1 THEN DO
  331.  
  332.               i        = batchcfg.0 - 1    /* Set new 'size' to 0 */
  333.               batchcfg.i.val = '  0K'
  334.  
  335.               i        = batchcfg.0 - 3    /* Set new 'name' to *.readme */
  336.               position = LASTPOS('.', batchcfg.i.val)
  337.  
  338.               IF position ~= 0 THEN DO
  339.                 batchcfg.i.val = SUBSTR(batchcfg.i.val, 1, position) || "readme"
  340.               END
  341.               ELSE DO
  342.                 batchcfg.i.val = batchcfg.i.val || ".readme"
  343.               END
  344.             END
  345.  
  346.             /* Do for all entry config lines */
  347.  
  348.             DO entrycfgnr=1 TO entrycfg.0
  349.  
  350.               line = entrycfg.entrycfgnr
  351.  
  352.               /* Replace batch and entry placeholders with value from config */
  353.               DO i=1 TO batchcfg.0
  354.  
  355.                 /* Replace all placeholders in line */
  356.                 start = POS(batchcfg.i.replace, line)
  357.                 DO WHILE start ~= 0
  358.  
  359.                   line  = SUBSTR(line,1,start-1) || SUBSTR(line,start+2)
  360.                   line  = INSERT(batchcfg.i.val, line, start-1)
  361.                   start = POS(batchcfg.i.replace, line)
  362.                 END
  363.               END
  364.  
  365.               CALL WRITELN(writehandle, line)
  366.             END
  367.           END
  368.         END
  369.       END
  370.       batchcfg.0 = batchcfg.0 - 4  /* Remove entry variables from config */
  371.     END
  372.  
  373.  
  374.     /* Read and Write batchmode extro file if available */
  375.  
  376.     filename = srcdir || "Configs/" || batchmode || ".extro"
  377.  
  378.     IF OPEN(handle, filename, 'R') THEN DO
  379.  
  380.       /* Do for all lines in file */
  381.       DO UNTIL EOF(handle)
  382.       
  383.         method ID CLS_BUSY MUIM_Busy_Move
  384.  
  385.         line = READLN(handle)
  386.  
  387.         /* Replace batch placeholders with value from config */
  388.         DO i=1 TO (batchcfg.0)
  389.  
  390.           /* Replace all placeholders in line */
  391.           start = POS(batchcfg.i.replace, line)
  392.           DO WHILE start ~= 0
  393.  
  394.             line  = SUBSTR(line,1,start-1) || SUBSTR(line,start+2)
  395.             line  = INSERT(batchcfg.i.val, line, start-1)
  396.             start = POS(batchcfg.i.replace, line)
  397.           END
  398.         END
  399.  
  400.         CALL WRITELN(writehandle, line)
  401.       END
  402.  
  403.       CALL CLOSE(handle)
  404.     END
  405.  
  406.     CALL CLOSE(writehandle)
  407.  
  408.     /* Copy icon for batchfile if available */
  409.  
  410.     ADDRESS COMMAND 'copy >NIL: "'srcdir'Configs/'batchmode'.info" "'outputfilename'.info"'
  411.  
  412.   END
  413.   ELSE DO
  414.     request ID RECSCRWIN TITLE '"File Error"' GADGETS "_OK" STRING "'Cannot write file '"filename"'"
  415.   END
  416.  
  417. END
  418. ELSE DO
  419.   request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot read '"batchmode"' configuration"
  420. END
  421.  
  422. RETURN
  423.  
  424.  
  425.  
  426. /* --------------------------------------------------------- */
  427. /* Save all entries from the LST_SEL to an AmiNet index file */
  428. /* --------------------------------------------------------- */
  429.  
  430. saveasindex: PROCEDURE EXPOSE srcdir
  431.  
  432. MUIA_List_Entries         = '0x80421654'
  433. MUIM_Busy_Move            = '0x80020001'
  434. ASLFR_InitialFile         = '0x80080008'
  435. ASLFR_InitialDrawer       = '0x80080009'
  436.  
  437.  
  438. OPTIONS FAILAT 11
  439. aslrequest ID RECSCRWIN TITLE '"Save selected files..."' ATTRS ASLFR_InitialDrawer srcdir ASLFR_InitialFile "RecentScript.lst"
  440. returncode = RC
  441. filename   = RESULT
  442. OPTIONS FAILAT 0
  443.  
  444. IF returncode = 0 & filename ~= '' THEN DO
  445.  
  446.   IF OPEN(handle, filename, 'W') THEN DO
  447.  
  448.     list ID LST_SEL ATTRS MUIA_List_Entries
  449.     number = RESULT
  450.  
  451.     IF number > 0 THEN DO
  452.  
  453.       DO i=0 TO number-1
  454.  
  455.         method ID CLS_BUSY MUIM_Busy_Move
  456.  
  457.         list ID LST_SEL POS i
  458.         line = RESULT
  459.  
  460.         /* This line must be edited if the format of the index file changes */
  461.         PARSE VAR line WITH 1 name +18 WITH 20 directory +10 WITH 31 size +4 WITH 36 comment
  462.  
  463.         CALL WRITELN(handle,name directory size comment)
  464.       END
  465.     END
  466.  
  467.     CALL CLOSE(handle)
  468.   END
  469.   ELSE DO
  470.     request ID RECSCRWIN TITLE '"File Error"' GADGETS "_OK" STRING "'Cannot write file '"filename"'"
  471.   END
  472. END
  473.  
  474.  
  475. RETURN
  476.  
  477.  
  478.  
  479. /* --------------------------------------------------------- */
  480. /* Delete all entries in specified listview                  */
  481. /* --------------------------------------------------------- */
  482.  
  483. clearlist: PROCEDURE
  484.  
  485. parse arg listid
  486.  
  487. list ID listid STRING
  488.  
  489. RETURN
  490.  
  491.  
  492.  
  493. /* --------------------------------------------------------- */
  494. /* (De)Select entries in LST_ALL with search string          */
  495. /* --------------------------------------------------------- */
  496.  
  497. patternentries: PROCEDURE
  498.  
  499. parse arg mode
  500.  
  501. MUIA_List_Entries         = '0x80421654'
  502. MUIM_List_Select          = '0x804252d8'
  503. MUIM_Busy_Move            = '0x80020001'
  504.  
  505. list ID LST_ALL ATTRS MUIA_List_Entries
  506. number = RESULT
  507.  
  508. string ID STR_PATT
  509. pattern = UPPER(RESULT)
  510.  
  511. IF number > 0 THEN DO
  512.  
  513.   DO i=0 TO number-1
  514.  
  515.     method ID CLS_BUSY MUIM_Busy_Move
  516.  
  517.     list ID LST_ALL POS i
  518.     line = UPPER(RESULT)
  519.  
  520.     IF POS(pattern, line) ~= 0 THEN DO
  521.  
  522.       method ID LST_ALL MUIM_List_Select i mode 0
  523.     END
  524.   END
  525. END
  526.  
  527. RETURN
  528.  
  529.  
  530.  
  531. /* --------------------------------------------------------- */
  532. /* Opens batch settings window for the specified batchmode   */
  533. /* --------------------------------------------------------- */
  534.  
  535. batchsettingopen: PROCEDURE EXPOSE portname srcdir
  536.  
  537. parse arg '['batchmode']'
  538.  
  539. Selected                  = '0x8042654b'
  540.  
  541. /* GUI Commands */
  542. CMD_BUT_OK     = '"'srcdir'RecentScriptCmd 'portname' SETBATHDL OK     ['batchmode']"'
  543. CMD_BUT_CANCEL = '"'srcdir'RecentScriptCmd 'portname' SETBATHDL CANCEL ['batchmode']"'
  544. CMD_BUT_DESC   = '"'srcdir'RecentScriptCmd 'portname' SETBATHDL DESC   ['batchmode']"'
  545.  
  546.  
  547. /* Read global batchmode config in local stem vraiable */
  548.  
  549. IF loadbatchconfigs('['batchmode']') = 1 THEN DO
  550.  
  551.   asdf = 'endgroup'  /* Workaround for an interpreting error (?) */
  552.  
  553.   /* Create window with string gadgets for each variable */
  554.  
  555.   window ID BATSETWIN TITLE '"Settings for '''batchmode'''"' PORT portname
  556.  
  557.     button COMMAND CMD_BUT_DESC HELP '"Shows batchmode description if available"' LABEL 'Description...' 
  558.  
  559.     group FRAME LABEL 'Global'
  560.       group HORIZ
  561.         space HORIZ
  562.         check ID CHK_README STRINGS '"0,1"' ATTRS Selected globalcfg.readme HELP '"Generate additional entry for the ''.readme'' file ?"'
  563.         label  "Include '#?.readme'"
  564.         space HORIZ
  565.       endgroup
  566.       group HORIZ
  567.         label  "Save to"
  568.         popasl ID PASL_FILE HELP '"Default filename for saving"' CONTENT globalcfg.file
  569.       endgroup
  570.     endgroup
  571.  
  572.     group FRAME LABEL 'Variables'
  573.  
  574.       DO i=1 TO batchcfg.0
  575.         group ID '"G'D2C(i+65)'"'
  576.           label CENTER '"'batchcfg.i.desc'"'
  577.           group HORIZ
  578.             label batchcfg.i.replace
  579.             string ID '"S'D2C(i+65)'"' HELP '"Replaces configuration variable ''%'D2C(i+48)''' in output"' CONTENT batchcfg.i.val
  580.           interpret asdf
  581.         interpret asdf
  582.       END i
  583.  
  584.     endgroup
  585.  
  586.     group HORIZ
  587.       button COMMAND CMD_BUT_OK     LABEL 'OK'
  588.       button COMMAND CMD_BUT_CANCEL LABEL 'Cancel'
  589.     endgroup
  590.  
  591.   endwindow
  592.  
  593. END
  594. ELSE DO
  595.   request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot read '"batchmode"' configuration"
  596. END
  597.  
  598. RETURN
  599.  
  600.  
  601.  
  602. /* --------------------------------------------------------- */
  603. /* Handle buttons from the batch settings window             */
  604. /* --------------------------------------------------------- */
  605.  
  606. batchsettinghandle: PROCEDURE expose srcdir portname
  607.  
  608. parse arg mode '['batchmode']'
  609.  
  610. MUIM_Busy_Move            = '0x80020001'
  611. MUIA_Frame                = '0x8042ac64'
  612. MUIA_Font                 = '0x8042be50'
  613. MUIA_List_Quiet           = '0x8042d8c7'
  614. MUIV_Frame_ReadList       =  5
  615. MUIV_List_Insert_Bottom   = -3
  616. MUIV_Font_Fixed           = -4
  617.  
  618. SELECT
  619.  
  620.   WHEN mode = 'DESC' THEN DO
  621.  
  622.    window ID HELPWIN CLOSE
  623.  
  624.    filename = srcdir || "Configs/" || batchmode || ".hlp"
  625.  
  626.     IF OPEN(handle, filename, 'R') THEN DO
  627.  
  628.       window ID HELPWIN TITLE '"Description of '''batchmode'''"' COMMAND '"window ID HELPWIN CLOSE"' PORT portname
  629.         list ID LST_HLP ATTRS MUIA_FRAME MUIV_Frame_ReadList MUIA_Font MUIV_Font_Fixed MUIA_List_Active MUIV_List_Active_Off
  630.       endwindow
  631.  
  632.       list ID LST_HLP ATTRS MUIA_List_Quiet 1
  633.  
  634.       /* Do for all lines in file */
  635.       DO UNTIL EOF(handle)
  636.       
  637.         line = READLN(handle)
  638.         
  639.         IF line = "" THEN line = "\n"
  640.  
  641.         list ID LST_HLP POS MUIV_List_Insert_Bottom INSERT STRING line
  642.       END
  643.  
  644.       list ID LST_HLP ATTRS MUIA_List_Quiet 0
  645.  
  646.       CALL CLOSE(handle)
  647.     END
  648.   END
  649.  
  650.   WHEN mode = 'CANCEL' THEN DO
  651.     window ID BATSETWIN CLOSE
  652.   END
  653.  
  654.   WHEN mode = 'OK' THEN DO
  655.  
  656.     /* Save global and variable configs to file */
  657.  
  658.     /* Read global config for description in local stem */
  659.  
  660.     IF loadbatchconfigs('['batchmode']') = 1 THEN DO
  661.  
  662.       /* Get new global config values in local stem */
  663.  
  664.       check ID CHK_README
  665.       globalcfg.readme = RESULT
  666.       popasl ID PASL_FILE
  667.       globalcfg.file = RESULT
  668.  
  669.  
  670.       /* Write global config to file */
  671.  
  672.       filename = srcdir || "Configs/" || batchmode || ".cfg"
  673.  
  674.       IF OPEN(handle, filename, 'W') THEN DO
  675.         CALL WRITELN(handle, globalcfg.readme)
  676.         CALL WRITELN(handle, globalcfg.file)
  677.         CALL CLOSE(handle)
  678.       END
  679.       ELSE DO
  680.         request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot write file '"filename"'"
  681.       END
  682.  
  683.  
  684.       filename = srcdir || "Configs/" || batchmode || ".var"
  685.  
  686.       /* Write variable batchmode config to file */
  687.  
  688.       IF OPEN(handle, filename, 'W') THEN DO
  689.  
  690.         DO i=1 TO batchcfg.0
  691.  
  692.           method ID CLS_BUSY MUIM_Busy_Move
  693.  
  694.           string ID '"S'D2C(i+65)'"'
  695.           batchcfg.i.val = RESULT
  696.  
  697.           CALL WRITELN(handle, batchcfg.i.desc)
  698.           CALL WRITELN(handle, batchcfg.i.val)
  699.         END
  700.  
  701.         CALL CLOSE(handle)
  702.       END
  703.       ELSE DO
  704.         request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot write file '"filename"'"
  705.       END
  706.     END
  707.     ELSE DO
  708.       request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot read '"batchmode"' configuration"
  709.     END
  710.  
  711.     window ID BATSETWIN CLOSE
  712.   END
  713.  
  714.   OTHERWISE DO
  715.     request ID RECSCRWIN TITLE '"Internal Error"' GADGETS '"_OK"' STRING '"Unsupport command 'batchmode'"'
  716.   END
  717. END
  718.  
  719. RETURN
  720.  
  721.  
  722.  
  723. /* --------------------------------------------------------- */
  724. /* Load global and variable configuration for batchmode      */
  725. /* --------------------------------------------------------- */
  726.  
  727. loadbatchconfigs: PROCEDURE EXPOSE srcdir globalcfg. batchcfg.
  728.  
  729. parse arg '['batchmode']'
  730.  
  731. /* Read global batchmode config in local stem vraiable */
  732.  
  733. filename = srcdir || "Configs/" || batchmode || ".cfg"
  734.  
  735. IF OPEN(handle, filename, 'R') THEN DO
  736.  
  737.   globalcfg.readme = READLN(handle)
  738.   globalcfg.file   = READLN(handle)
  739.  
  740.  
  741.   /* START Only upgrade code to read old configs from V1.0 */
  742.   batchcfg.0 = 0
  743.   i          = 0
  744.  
  745.   DO UNTIL EOF(handle)
  746.  
  747.     method ID CLS_BUSY MUIM_Busy_Move
  748.  
  749.     description = READLN(handle)
  750.     value       = READLN(handle)
  751.  
  752.     IF description ~= '' & value ~= '' THEN DO
  753.  
  754.       i = i + 1
  755.       batchcfg.0 = i
  756.  
  757.       batchcfg.i.replace = '%'D2C(i+48)''   /* %1 ... */
  758.       batchcfg.i.desc    = description
  759.       batchcfg.i.val     = value
  760.     END
  761.   END
  762.   /* END Only upgrade code to read old configs from V1.0 */
  763.  
  764.   CALL CLOSE(handle)
  765.  
  766.  
  767.   /* Read variable batchmode config in local stem variable */
  768.  
  769.   filename = srcdir || "Configs/" || batchmode || ".var"
  770.  
  771.   IF OPEN(handle, filename, 'R') THEN DO
  772.  
  773.     batchcfg.0 = 0
  774.     i = 0
  775.  
  776.     DO UNTIL EOF(handle)
  777.  
  778.       method ID CLS_BUSY MUIM_Busy_Move
  779.  
  780.       description = READLN(handle)
  781.       value       = READLN(handle)
  782.  
  783.       IF description ~= '' & value ~= '' THEN DO
  784.  
  785.         i = i + 1
  786.         batchcfg.0 = i
  787.  
  788.         batchcfg.i.replace = '%'D2C(i+48)''   /* %1 ... */
  789.         batchcfg.i.desc    = description
  790.         batchcfg.i.val     = value
  791.       END
  792.     END
  793.  
  794.     CALL CLOSE(handle)
  795.  
  796.     RETURN 1
  797.  
  798.   END
  799. END
  800. ELSE DO
  801.   request ID RECSCRWIN TITLE '"File Error"' GADGETS '"_OK"' STRING "Cannot read file '"filename"'"
  802.   RETURN 0
  803. END
  804.  
  805.  
  806. /* --------------------------------------------------------- */
  807. /* Only a testprocedure for testing new features             */
  808. /* --------------------------------------------------------- */
  809.  
  810. testprocedure: PROCEDURE
  811.  
  812. RETURN
  813.